1. Field of the Invention
The present invention generally relates to an image processing apparatus and, more particularly, to a technique for morphologically processing an image masked with a given mesh pattern.
2. Related Art
Morphology is one known process for removing noise from various types of images. In morphological processing, images are processed using dilation, erosion, opening, and closing independently or in combination.
Dilation is a process in which the maximum value (Minkowski sum) within the range of ±m from a pixel of interest is searched for, where m depends on the structuring element. Erosion is a process in which the minimum value (Mincowski difference) within the range of ±m from a pixel of interest is searched for. Opening consists of a erosion followed by dilation; that is, the minimum value is first searched for and then the maximum value is searched for. Closing consists of a dilation followed by erosion; that is, the maximum value is first searched for and then the minimum value is searched for. These operations are used for removing isolated points, connecting discontinuous points, or filling up gaps.
FIGS. 10 to 12 schematically show dilation and erosion operations. FIG. 10A shows a structuring element (kernel); FIG. 10B shows the directions of displacement of the structuring element. The four structuring elements existing in four positions, top, bottom, left, and right, means that the original image is to be displaced in the four directions a, b, c, and d by one pixel.
FIG. 11 shows an image resulting from displacing the original image in the directions shown in FIG. 10B. In FIG. 11, image “a” is an image resulting from the displacement of the original image in direction a shown in FIG. 10B by one pixel, image “b” is an image resulting from the displacement of the original image in direction b shown in FIG. 10B by one pixel, image “c” is an image resulting from the displacement of the original image in direction c shown in FIG. 10B by one pixel, and image “d” is an image resulting from the displacement of the original image in direction d shown in FIG. 10B by one pixel.
FIG. 12A shows the Minkowski sum (all regions where the image exists) of the original image and the four images a to d shown in FIG. 11, that is, the result of dilation. FIG. 12B shows the Minkowski difference (only the common region) of the original image and the four images a to d shown in FIG. 11, that is, the result of erosion. Techniques in which morphological operations are used to reduce noise in images are described in Japanese Patent Laid-Open Publication No. Hei 11-259651 and No. 2002-94799.
When a printed circuit board image passed through a screen mask as shown in FIG. 13 is inspected and the width A and diameter B of wiring is to be measured, typically only the distances between the edges are measured. However, although such measurement require the detection of the edges, detection can be problematic when the image is masked with a mesh pattern as shown.
FIG. 14 shows an enlarged view of a portion of the wiring pattern shown in FIG. 13. Because the wiring pattern is separated into regions by the presence of the mesh pattern, boundaries 200 inside the wiring pattern, which are not actual edges, are also detected in addition to the edges 100 of the actual wiring pattern. Therefore, the width A or diameter B of the wiring cannot accurately measured from these edges. Regions, such as regions a and b, in FIG. 14 formed as a result of the presence of the mesh pattern are referred to as openings herein and the gap between such regions is referred to as an opening gap (the width of the mesh pattern).
Morphological operations maybe used to remove the mesh pattern from the original image to obtain the image of the wiring pattern alone prior to performing the edge detection of the wiring pattern. That is, dilation may be performed on the original image, a visual check may be made to see that the mesh pattern is filled up, and then erosion may be performed to restore the dilated portion, thus removing the mesh pattern.
However, it is desirable that the number of morphological operations be minimized in order to minimize deformation of the image, because dilation and erosion are irreversible processes that cannot restore the original image. It is desirable that the number of the dilation operations and the number of the erosion operations should be minimized